package jacker.bit.price;

import org.json.JSONObject;

import android.content.Context;

public class PlatformMtgox implements Platform {

	@Override
	public String getCode() {
		return "mtgox";
	}

	@Override
	public String getName(Context ctx) {
		return ctx.getString(R.string.platform_mtgox);
	}

	@Override
	public float getPrice() throws Exception{
		String result = PriceChecker.httpGet("http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast");
		JSONObject json = new JSONObject(result);
		return Float.parseFloat(json.getJSONObject("data").getJSONObject("last").getString("value"));
		//int start = result.indexOf("value");
		//int end = result.indexOf(",",start)-1;
		//return Float.parseFloat(result.substring(start+8,end));
	}

	@Override
	public String getCurrency() {
		// TODO Auto-generated method stub
		return "$";
	}
	
	

}
